#ifndef DOWNLOADMANAGER_H
#define DOWNLOADMANAGER_H

#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QFile>
class DownLoadManager : public QObject
{
    Q_OBJECT
public:
    explicit DownLoadManager( QObject *parent = 0);
    virtual ~DownLoadManager();
    void setDownInto(bool);
    QString getDownloadUrl();
    void downloadFile(QString, QString);
    void stopWork();
    void stopDownload();
    void reset();
    void removeFile(QString);
    void closeDownload();
private slots:
    void onReadyRead();
    void onFinished();
    void onError(QNetworkReply::NetworkError);
    void onDownloadProgress(qint64, qint64);
signals:
    void signalDownloadProcess(qint64,qint64);
    void signalReplyFinished(int);
    void signalDownloadError();
private:
    QNetworkAccessManager *m_networkManager;
    QUrl m_url;
    QString m_fileName;
    bool m_isSupportBreakPoint;
    int m_bytesReceived = 0;
    int m_bytesTotal = 0;
    int m_bytesCurrentReceived = 0;
    bool m_isStop;
    QNetworkReply *m_reply;
    QFile *filePoint;    //文件指针
};

#endif // DOWNLOADMANAGER_H
